<?php
/*
带cookie的简单请求
 */

// header("Access-Control-Allow-Origin:http://test1.com");

$origin = isset($_SERVER['HTTP_ORIGIN'])? $_SERVER['HTTP_ORIGIN'] : '';//获取客户端请求头参数Origin
header('Access-Control-Allow-Origin:'.$origin);
header("Access-Control-Allow-Credentials:true");

$arr = array(
    "user" => $_POST['username'],
    "pass" => $_POST['password'],
);

setcookie("user", "runoob", time()+3600);

echo json_encode($arr);
?>
